package mil.af.amc.adpetracker.model;

import org.springframework.security.GrantedAuthority;

import javax.persistence.*;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */
@Entity
@Table(name="T_AUTHORITYNAME")
public class Authority implements GrantedAuthority {

    private int id;
    private String authority;

    public Authority() {
    }

    public Authority(String role) {
        this.authority = role;
    }

    @Id
    @Column(name="ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name="NAME")
    public String getAuthority() {
        return this.authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public int compareTo(Object o) {

        Authority that = (Authority) o;
        return this.authority.compareTo(that.getAuthority());
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Authority authority1 = (Authority) o;

        if (authority != null ? !authority.equals(authority1.authority) : authority1.authority != null) return false;

        return true;
    }

    public int hashCode() {
        return (authority != null ? authority.hashCode() : 0);
    }
}
